[20250730] BOJ / G4 / 이중 우선순위 큐 / 이인희 #579
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/7662
🧭 풀이 시간
60 분
👀 체감 난이도
✏️ 문제 설명
이중 우선순위 큐: 우선순위 큐의 삽입은 동일, 삭제일땐 가장 높은 데이터를 지우거나 가장 낮은 데이터를 지우는 것에서 다름
이 이중 우선순위 큐에 대해 삭제, 삽입이 input으로 여러번 주어지고, 그 중 하나의 상태에서 큐안에 존재하는 최댓값과 최솟값을 출력하는 프로그램
🔍 풀이 방법
⏳ 회고
우선순위 큐 두개를 사용하는 방법을 시도하다가 잘 안풀렸다. 그래서 찾아본 결과 TreeMap을 이용해, 가장 높은키, 낮은 키를 O(logN)에 구할 수 있다는 것을 알았다. 또한, 우선순위 큐 두개를 활용하는 방법을 사용하기 위해선 이를 동기화 해주는 HashMap을 사용하면 된다고한다. 나중에 다시 풀어볼것.